<template>
	<view class="devicelist"> 
		<u-navbar title="设备列表" back-icon-color="#fff"
			:background="{backgroundImage: 'linear-gradient(45deg, #68dae7, #21a4b3)'}" title-color="#FFFFFF">
		</u-navbar>
		<view class="devicelist-list">
			<view class="devicelist-list-item" v-for="(item,index) in deviceList" :key="index" @tap.stop="goto('pages/home/deviceInfo',item.id)">
				<view class="devicelist-list-item-name">{{item.deviceName}}</view>
				<view class="devicelist-list-item-info">
					<view class="devicelist-list-item-info-sn">资产编号:{{item.assetNumber}}</view>
					<view v-if="item.status == 1" class="devicelist-list-item-info-status normal">正常</view>
				</view>
				<view class="devicelist-list-item-describe">
					<view>仪器信息:</view>
					<view>{{item.describe?item.describe:""}}</view>
					<!-- <view>清单2</view>
					<view>清单3</view> -->
				</view>
				<view>负责人：{{item.owner?item.owner:""}}</view>
				<view class="devicelist-list-item-footer">
					<view class="devicelist-list-item-footer-btn-maintenance" @tap.stop="goto('pages/home/maintenance',item.id)">维修记录</view>
					<view class="devicelist-list-item-footer-btn-Inspection" v-if="item.isXj == 2" @tap.stop="goto('pages/home/Inspection',item.id)">巡检记录</view>
					<view class="devicelist-list-item-footer-btn-Inspection" v-if="item.isHc == 2" @tap.stop="goto('pages/home/check',item.id)">核查记录</view>
					<view class="devicelist-list-item-footer-btn-Inspection" v-if="item.isBy == 2" @tap.stop="goto('pages/home/mainList',item.id)">保养记录</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return {
				deviceList:[],
				pageSize:5,
				pageNumber:1,
			}
		},
		onLoad(){
			this.getData()
		},
		onPullDownRefresh() {
			this.deviceList = []
			this.getData()
		},
		methods:{
			getData(){
				let params = {
					pageSize: this.pageSize,
					pageNumber: this.pageNumber
				}
				this.$xt.api.deviceList(params).then(res=>{
					this.deviceList = this.deviceList.concat(res.rows)
				})
			},
			goto(url,id){
				this.$u.route({
					url:url,
					type:"navigateTo",
					params:{
						deviceSn:id
					}
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.devicelist{
		&-list{
			background-color: #f4f4f4;
			&-item{
				background-color: #fff;
				margin-bottom: 10rpx;
				padding: 10rpx 24rpx;
				&-name{
					color:#00557f;
					font-size: 30rpx;
					font-weight: 600;
				}
				&-info{
					display: flex;
					justify-content: space-between;
					align-items: center;
					&-status{
						padding: 5rpx 10rpx;
						border-radius: 5rpx;
					}
				}
				&-describe{
					color: #aaa;
					padding-left: 10rpx;
				}
				&-footer{
					display: flex;
					justify-content: space-between;
					margin-top: 10rpx;
					&-btn{
						display: flex;
						justify-content: flex-end;
						&-maintenance{
							padding: 10rpx 24rpx;
							background-color: #dd6f38;
							color:#fff;
							border-radius: 15rpx;
							// margin-right: 20rpx;
						}
						&-Inspection{
							padding: 10rpx 24rpx;
							background-color: #00aa00;
							color:#fff;
							border-radius: 15rpx;
						}
					}
				}
				
			}
		}
	}
	.normal{
		background-color: #00aa7f;
		color:#fff
	}
</style>